/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package pe.edu.upc.dew.discoteca.model;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

/**
 *
 * @author elvis
 */
@Entity
@Table(name = "contacto")
@NamedQueries({@NamedQuery(name = "Contacto.findAll", query = "SELECT c FROM Contacto c"), @NamedQuery(name = "Contacto.findByCodigo", query = "SELECT c FROM Contacto c WHERE c.codigo = :codigo"), @NamedQuery(name = "Contacto.findByNombre", query = "SELECT c FROM Contacto c WHERE c.nombre = :nombre"), @NamedQuery(name = "Contacto.findByApellido", query = "SELECT c FROM Contacto c WHERE c.apellido = :apellido"), @NamedQuery(name = "Contacto.findByCorreo", query = "SELECT c FROM Contacto c WHERE c.correo = :correo"), @NamedQuery(name = "Contacto.findByFacebooktoken", query = "SELECT c FROM Contacto c WHERE c.facebooktoken = :facebooktoken"), @NamedQuery(name = "Contacto.findByFoto", query = "SELECT c FROM Contacto c WHERE c.foto = :foto")})
public class Contacto implements Serializable {
   private static final long serialVersionUID = 1L;
   @Id
   @GeneratedValue(strategy = GenerationType.AUTO)
   @Basic(optional = false)
   @Column(name = "codigo")
   private Integer codigo;
   @Column(name = "nombre")
   private String nombre;
   @Column(name = "apellido")
   private String apellido;
   @Column(name = "correo")
   private String correo;
   @Column(name = "facebooktoken")
   private String facebooktoken;
   @Column(name = "foto")
   private String foto;
   @JoinColumn(name = "codigoLista", referencedColumnName = "codigo")
   @ManyToOne(optional = false,  cascade=CascadeType.ALL)
   private Lista codigoLista;

   public Contacto() {
   }

   public Contacto(Integer codigo) {
      this.codigo = codigo;
   }

    public Contacto(String facebooktoken, String name, String picture) {
       this.facebooktoken=facebooktoken;
       this.nombre=name;
       this.foto=picture;
   }

   public Contacto(String facebooktoken, String name, String picture, Lista milista) {
       this.facebooktoken=facebooktoken;
       this.nombre=name;
       this.foto=picture;
       this.codigoLista=milista;
   }

   public Integer getCodigo() {
      return codigo;
   }

   public void setCodigo(Integer codigo) {
      this.codigo = codigo;
   }

   public String getNombre() {
      return nombre;
   }

   public void setNombre(String nombre) {
      this.nombre = nombre;
   }

   public String getApellido() {
      return apellido;
   }

   public void setApellido(String apellido) {
      this.apellido = apellido;
   }

   public String getCorreo() {
      return correo;
   }

   public void setCorreo(String correo) {
      this.correo = correo;
   }

   public String getFacebooktoken() {
      return facebooktoken;
   }

   public void setFacebooktoken(String facebooktoken) {
      this.facebooktoken = facebooktoken;
   }

   public String getFoto() {
      return foto;
   }

   public void setFoto(String foto) {
      this.foto = foto;
   }

   public Lista getCodigoLista() {
      return codigoLista;
   }

   public void setCodigoLista(Lista codigoLista) {
      this.codigoLista = codigoLista;
   }

   @Override
   public int hashCode() {
      int hash = 0;
      hash += (codigo != null ? codigo.hashCode() : 0);
      return hash;
   }

   @Override
   public boolean equals(Object object) {
      // TODO: Warning - this method won't work in the case the id fields are not set
      if (!(object instanceof Contacto)) {
         return false;
      }
      Contacto other = (Contacto) object;
      if ((this.codigo == null && other.codigo != null) || (this.codigo != null && !this.codigo.equals(other.codigo))) {
         return false;
      }
      return true;
   }

   @Override
   public String toString() {
      return "pe.edu.upc.dew.discoteca.model2.Contacto[codigo=" + codigo + "]";
   }

}
